package com.ysd.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ysd.dao.Impl.ChanPinMoHuDaoImpl;
import com.ysd.dao.Impl.ProductCatalogueDaoImpl;
import com.ysd.entity.Product;
import com.ysd.entity.ProductCatalogue;

public class ChanPinMoHuServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	     request.setCharacterEncoding("UTF-8");
	     response.setContentType("text/html");
	     HttpSession session=request.getSession();
	     //搜索时显示产品分类
	     ProductCatalogueDaoImpl pDao=new ProductCatalogueDaoImpl();
		 List<ProductCatalogue> pclist=pDao.getPCList();
		 request.setAttribute("pclist", pclist);
	     //模糊查询
	     String mohu=request.getParameter("mohu");
	     ChanPinMoHuDaoImpl mhDao=new ChanPinMoHuDaoImpl();
	     ArrayList<Product> chanpinmohu=mhDao.getChanPinMoHu(mohu);
	     System.out.println(chanpinmohu);
	     request.setAttribute("cpmh",chanpinmohu);
	     session.setAttribute("cpmh", chanpinmohu);
	     request.getRequestDispatcher("NewFile.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
